#pragma once

#include "segment.h"

namespace trm {

class target_frame
{
public:
	target_frame(segment & segm);
	~target_frame();
	void create(unsigned time);
	void create(direction dir, unsigned offset);

	void swap(target_frame & t);

	segment & segm() const
		{ return _segm; }
	unsigned time() const
		{ return _time; }
	unsigned segtime(direction * dir = 0) const
		{ return _segm.segtime(_time, dir); }
	byte_image const & image() const
		{ return _image->im; }
	byte_image const & downsampled_image() const
		{ return _downsampled_image.empty() ? _image->im : _downsampled_image; }
	::float_image const & float_image() const
		{ return _float_image; }

protected:
	mswin::timing_tree & timing_tree()
		{ return _segm._timing; }
	mswin::timing_mark timing_mark(std::string const & name)
		{ return mswin::timing_mark(_segm._timing, name); }

private:
	segment &			_segm;
	unsigned			_time;
	icache::cached_image_sptr _image;
	::byte_image		_downsampled_image;
	::float_image		_float_image; ///< not empty only if optic_flow is true in segment's param, also downsamples
};

} //namespace trm
